package com.bdsy.business.controller;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bdsy.api.annotation.IgnoreAuth;
import com.bdsy.business.model.ShopFollow;
import com.bdsy.business.service.ShopFollowSevice;
import com.bdsy.common.utils.Result;

@Controller
@RequestMapping(value = {"${web.adminPath}", "${web.appPath}"})
public class ShopFollowController {

	@Autowired
	private ShopFollowSevice shopFollowSevice;
	
	/**
	 * 
	    * @Title: addShopFollow
	    * @Description: 添加关注
	 */
	@IgnoreAuth
	@RequestMapping("/addShopFollow")
	@ResponseBody
	public Object addShopFollow(ShopFollow shopFollow) {
		boolean result = shopFollowSevice.add(shopFollow);
		if (result) {
			return Result.ok("添加成功");
		} else {
			return Result.error("添加失败");
		}
	}
	
	/**
	 * 
	    * @Title: selectShopFollwById
	    * @Description: 查看关注竞拍信息
	 */
	@IgnoreAuth
	@RequestMapping("/selectShopFollwById")
	@ResponseBody
	public Object selectShopFollwById(String userId) {
		@SuppressWarnings("rawtypes")
		List<Map> shopFollwList = shopFollowSevice.selectShopFollwById(userId);
		Map<String,Object> map = new LinkedHashMap<>();
		map.put("code", 200);
		map.put("msg", "success");
		map.put("shopFollwList", shopFollwList);
		return  map;
	}
	
	/**
	 * 
	    * @Title: deleteShopFollwById
	    * @Description: TODO 取消关注
	 */
	@IgnoreAuth
	@RequestMapping("/deleteShopFollwById")
	@ResponseBody
	public Object deleteShopFollwById(String userId,int shopId) {
		boolean result = shopFollowSevice.delete(userId, shopId);
		if (result) {
			return Result.ok("取消关注成功");
		} else {
			return Result.error("取消关注失败");
		}
	}
}
